package cn.edu.zut.qixiang.flink;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author 86178
 */
@Data
@AllArgsConstructor
public class WeatherAlert {
    private String district;
    private Double temperature;
    private Double windSpeed;
    private LocalDateTime alertTime;

    public String getAlertMessage() {
        StringBuilder message = new StringBuilder();
        message.append("【天气预警】").append(district);

        if (temperature > 35.0) {
            message.append(" 高温预警: ").append(temperature).append("°C");
        }
        if (windSpeed > 10.0) {
            if (message.length() > 0) message.append(" | ");
            message.append(" 大风预警: ").append(windSpeed).append("m/s");
        }

        return message.toString();
    }
}